package com.jason.pulltorefreshandstickylistheaders.view;

import android.content.Context;
import android.util.AttributeSet;

import com.handmark.pulltorefresh.library.PullToRefreshBase;
import com.jason.pulltorefreshandstickylistheaders.R;

import se.emilsjolander.stickylistheaders.StickyListHeadersListView;

/**
 * @Author: Jason
 * @Date: 16/6/12
 * @Time: 15:56
 */

public class PullToRefreshStickyListView extends PullToRefreshBase<StickyListHeadersListView> {


    public PullToRefreshStickyListView(Context context) {
        super(context);
    }

    public PullToRefreshStickyListView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public Orientation getPullToRefreshScrollDirection() {
        return Orientation.VERTICAL;
    }

    @Override
    protected StickyListHeadersListView createRefreshableView(Context context, AttributeSet attrs) {
        StickyListHeadersListView view = new StickyListHeadersListView(context, attrs);
        view.setId(R.id.sticky_header);
        return view;
    }

    @Override
    protected boolean isReadyForPullEnd() {
        return false;
    }

    @Override
    protected boolean isReadyForPullStart() {
        StickyListHeadersListView view = getRefreshableView();
        if (view.getWrappedList().getChildCount() == 0)
            return true;
        return view.getWrappedList().getChildAt(0).getTop() == 0;
    }



}
